#include<iostream>
#include<cstdio>
using namespace std;
struct node{
	int data;
	node *next;
} *r,*p,*head;
int main()
{
	int n;
	cin>>n;
	int data_in;
	head=new node;
	head->next=NULL;
	r=head;
	for (int i=1;i<=n;i++)
	{
		cin>>data_in;
		p=new node;
		p->data=data_in;
		p->next=NULL;
		r->next=p;
		r=p;
	}
	p=head;
	int del;
	cin>>del;
	while(p!=NULL)
    {
    	node *s=p->next;
        if(s&&s->data==del)
        {
            p->next=p->next->next;
            free(s);
        }
        else p=p->next;
    }
    p=head->next;
    while(p->next!=NULL)
    {
        cout<<p->data<<' ';
        p=p->next;
    }
    cout<<p->data<<endl;
    return 0;
}